package com.learning.dubbo.service.validation.consumer;

import com.learning.dubbo.service.validation.api.ValidationParameter;
import com.learning.dubbo.service.validation.api.ValidationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

/**
 * ClassName: Consumer
 * Description: 消费客户端
 * Date: 2020/6/15 13:43 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Slf4j
public class Consumer {
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml");
        context.start();

        // 获取远程服务代理
        ValidationService validationService = (ValidationService) context.getBean("validationService");
        // 执行远程方法

        // @Min(1) 校验
        validationService.delete(0);

        ValidationParameter parameter = new ValidationParameter();
        parameter.setName("sam");
        parameter.setEmail("sam@163.com");
        parameter.setAge(1000);
        parameter.setExpiryDate(new Date());
        parameter.setLoginDate(new Date());

        validationService.save(parameter);
        // 代理对象
        log.info(validationService.getClass().getName());
        context.close();
    }
}
